/**
 * 
 */
package edu.gtcfla.km.appmodules.service.impl;

import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.vsg.biz.BusinessOperationException;
import org.vsg.common.model.json.SelectItem;

import edu.gtcfla.km.FileFormat;
import edu.gtcfla.km.appmodules.service.FileFormatService;
import edu.gtcfla.km.repositories.FileFormatRepo;

/**
 * @author vison
 *
 */
public class FileFormatServiceI implements FileFormatService {
	
	@Autowired(required=false)	
	private FileFormatRepo<FileFormat , String> fileFormatRepo;

	/* (non-Javadoc)
	 * @see edu.gtcfla.km.appmodules.service.FileFormatService#findAllFileFormat()
	 */
	@Override
	public Set<SelectItem> findAllFileFormat()
			throws BusinessOperationException {
		// TODO Auto-generated method stub
		Map<String,FileFormat>  fileFormatAll = fileFormatRepo.findAllMap();
		
		Set<SelectItem> resultItems = new LinkedHashSet<SelectItem>();
		
		SelectItem selItem = new SelectItem();
		selItem.setId("all");
		selItem.setName("全部");
		resultItems.add( selItem );
		
		for (Map.Entry<String, FileFormat>  item : fileFormatAll.entrySet() ) {
			
			selItem = new SelectItem();
			selItem.setId( item.getValue().getId() );
			selItem.setName( item.getValue().getName() );
			
			resultItems.add( selItem );
		}
		
		return resultItems;
	}

}
